package com.bysj.servelt;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bysj.model.Comment;
import com.bysj.model.Order;
import com.bysj.model.Reply;
import com.bysj.service.CommentService;
import com.bysj.service.OrderService;

/**
 * Servlet implementation class OrderCommentSeeServlet
 */
@WebServlet("/admin/order_reply_see")
public class AdminOrderReplySeeServlet extends HttpServlet {
	private OrderService oService = new OrderService();
	private CommentService cService = new CommentService();

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int orderId = Integer.parseInt(request.getParameter("orderId"));

		Order order = oService.getOrder(orderId);
		request.setAttribute("order", order);

		Comment c = cService.getOrderComment(orderId);
		request.setAttribute("c", c);

		Reply r = cService.getCommentReply(orderId);
		request.setAttribute("r", r);

		request.getRequestDispatcher("/admin/reply_see.jsp").forward(request, response);
	}

}
